import java.util.Random;
import java.util.Scanner;

/**
 * @Author 12629
 * @Description：
 */
public class Test {

    public static void main(String[] args) {
        int a = 10;
        int b = 20;
        System.out.println("a: "+a +" b: "+b);
        swap(a,b);
        System.out.println("a: "+a +" b: "+b);
    }

    public static void swap(int x,int y) {
        int tmp = x;
        x = y;
        y = tmp;
    }


    public static void main9(String[] args) {
        System.out.println(facSum(5));
        System.out.println("=====================");
        func1(1,2);
        System.out.println(func2(1,2));
        System.out.println("=====================");
        int ret = func2(1,2);
        System.out.println(maxNum(ret, 5));//有返回值 就可以支持链式表达式
    }

    public static void func1(int a,int b) {
        System.out.println(a+b);
    }

    public static int func2(int a,int b) {
        return a+b;
    }

    public static int maxNum(int a,int b) {
        return a > b ? a: b;
    }

    public static int facSum(int n) {
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += fac(i);
        }
        return sum;
    }

    public static int fac(int n) {
        int ret = 1;
        for (int i = 1; i <= n; i++) {
            ret *= i;
        }
        return ret;
    }

    public static void main8(String[] args) {
        int year = 2024;
        boolean flg = isLeapYear(year);
        if(flg) {
            System.out.println("是闰年");
        }
    }

    /**
     * 方法名采用小驼峰的形式  maxNum
     * @param year 年
     * @return
     */
    public static boolean isLeapYear(int year) {
        if((0 == year % 4 && 0 != year % 100) || 0 == year % 400){
            //System.out.println(year+"年是闰年");
            return true;
        }
        return false;
    }

    public static int add(int a,int b) {
        int ret = a+b;
        return ret;
    }






    public static void main7(String[] args) {
        int count = 3;
        Scanner in = new Scanner(System.in);
        while (count != 0) {
            System.out.println("请输入你的密码：");
            String password = in.nextLine();
            if(password.equals("123456")) {
                System.out.println("登录成功！");
                break;
            }else {
                count--;
                System.out.println("你还有 " + count +" 次机会！");
            }
        }
    }
    public static void main6(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {
            int a = in.nextInt();
            System.out.println(a);
        }
    }
    public static void main5(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            for(int i = 0;i < n;i++) {
                for(int j = 0;j < n;j++) {
                    if(i == j || (i+j) == n-1) {
                        System.out.print("*");
                    }else {
                        System.out.print(" ");
                    }
                }
                System.out.println();
            }
        }
    }
    public static void main4(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //生成随机数
        Random random = new Random();
        int randNum = random.nextInt(100);//[0-100) TODO: 思考 50-100之间的随机数怎么生成
        while (true) {
            System.out.println("请输入你要删除数字：");
            int n = scanner.nextInt();
            if(n > randNum) {
                System.out.println("猜大了！");
            }else if(n == randNum) {
                System.out.println("猜对了！");
                return;
            }else {
                System.out.println("猜小了！");
            }
        }
    }





    public static void main3(String[] args) {
        for (int i = 0; i < 999999; i++) {
            int count = 0;
            int tmp = i;
            while (tmp != 0) {
                count++;
                tmp /= 10;
            }
            int sum = 0;
            tmp = i;//153
            while (tmp != 0) {
                sum += Math.pow(tmp%10,count);
                tmp /= 10;
            }
            if(sum == i) {
                System.out.println(i);
            }
        }
    }
    public static void main2(String[] args) {
        int n = 7;
        int i = 2;
        for (; i <= Math.sqrt(n); i++) {
            if(n % i == 0) {
                System.out.println(n + " 不是素数");
                break;
            }
        }
        if(i > Math.sqrt(n)) {
            System.out.println(n+" 是素数！！！");
        }

        //Math.pow(2,3);
    }


    public static void main1(String[] args) {
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            if(i % 10 == 9) {
                count++;
            }else if(i / 10 == 9) {
                count++;
            }
        }
        System.out.println(count);
    }
}
